package com.fox0g.filter;

public class RecursiveAverageFilter {
    private double[] data;
    private double[] filteredData;
    private int windowSize;

    public void setData(double[] data) {
        this.data = data;
    }

    public RecursiveAverageFilter() {
//        this.data = data;
        this.windowSize = 5;
        this.filteredData = new double[this.data.length];

        // 计算第一个滤波值
        filteredData[0] = this.data[0];

        // 递推计算滤波值
        for (int i = 1; i < this.data.length; i++) {
            filteredData[i] = (filteredData[i - 1] * (i - 1) + this.data[i]) / i;
        }
    }

    public double[] getFilteredData() {
        return filteredData;
    }



    }
